import Http from '@/utils/axios'
//签名
import _bale from '@/utils/package'
//接口地址
import * as url from '@/utils/apiUrl'
import qs from 'qs'
//参数序列化
import { GetParamString } from '@/utils/mixin'

//member

//app端用户账号密码登录

export const doLogin = params =>
  new Http().require({
    api: url.server_sso + '/login/appdoLogin',
    param: qs.stringify(_bale('appdoLogin', params))
  })

//金桥一卡通
export const jqLogin = params =>
  new Http().require({
    api: url.server_sso + '/wx/jqUserLogin',
    param: qs.stringify(_bale('jqUserLogin', params))
  })

//验证用户账号是否可用

export const validateAccount = params =>
  new Http().require({
    api: url.server_sso + '/userService/validateAccount',
    param: qs.stringify(_bale('validateAccount', params))
  })

//用户发送手机验证码
export const sendPhoneCode = params =>
  new Http().require({
    api: url.server_sso + '/userService/sendPhoneCode',
    param: qs.stringify(_bale('sendPhoneCode', params))
  })
//验证手机验证码
export const validateCode = params =>
  new Http().require({
    api: url.server_sso + '/userService/validatePhoneCode',
    param: qs.stringify(_bale('validatePhoneCode', params))
  })
//设置密码
export const registered = params =>
  new Http().require({
    api: url.server_sso + '/userService/app/register',
    param: qs.stringify(_bale('register', params))
  })
//获取个人信息
export const getUserInfo = params =>
  new Http().require({
    api: url.server_sso + '/userService/app/getUserInfo',
    param: qs.stringify(_bale('getUserInfo', params))
  })

//获取地址详细信息
export const getAddressList = params =>
  new Http().require({
    api: url.server_shop + '/userAddress/seleteUserAddressList',
    param: qs.stringify(_bale('seleteUserAddressList', params))
  })
//新建地址
export const saveAddress = params =>
  new Http().require({
    api: url.server_shop + '/userAddress/addUserAddress',
    param: qs.stringify(_bale('addUserAddress', params))
  })

//新建地址
export const getAddress = params =>
  new Http().require({
    api: url.server_shop + '/userAddress/selectUserAddress',
    param: qs.stringify(_bale('selectUserAddress', params))
  })

//获取金桥卡号
export const getUserCard = params =>
  new Http().require({
    api: url.server_sso + '/wx/getJqUserCard',
    param: qs.stringify(_bale('getJqUserCard', params))
  })

export const sendEPayPhoneCode = params =>
  new Http().require({
    api: url.server_shop + '/wx/sendSms',
    param: qs.stringify(_bale('sendSms', params))
  })

//shop

//搜索商品
export const searchGoods = params =>
  new Http().require({
    api: url.server_search + '/jqSearch' + GetParamString(params),
    methods: 'get'
  })
//获取商品详情
export const getGoodsDetails = params =>
  new Http().require({
    api: url.server_shop + '/mallGoods/getGoodsDetails',
    param: qs.stringify(_bale('getGoodsDetails', params))
  })
//获取尺码信息
export const getSpecInfo = params =>
  new Http().require({
    api: url.server_shop + '/mallGoods/getSupplierInfo',
    param: qs.stringify(_bale('getSupplierInfo', params))
  })
//金桥加入购物车
export const addShopCart = params =>
  new Http().require({
    api: url.server_shop + '/app/index/add_jin_qiao_shop_cart',
    param: qs.stringify(_bale('add_jin_qiao_shop_cart', params))
  })

// 获取购物车商品列表
export const getCartProductList = params =>
  new Http().require({
    api: url.server_shop + '/mallGoods/getShopCart',
    param: qs.stringify(_bale('getShopCart', params))
  })

// 修改购物车的数量
export function updateProCount(params) {
  new Http().require({
    api: url.server_shop + '/mallGoods/updateShopCart',
    param: qs.stringify(_bale('updateShopCart', params))
  })
}

// 删除购物车尺码
export function delCartPro(params) {
  new Http().require({
    api: url.server_shop + '/mallGoods/deleteShopCart',
    param: qs.stringify(_bale('deleteShopCart', params))
  })
}
// 购物车结算验证商品库存
export function validateCartNum(params) {
  new Http().require({
    api: url.server_shop + '/mallGoods/validateShopCart',
    param: qs.stringify(_bale('validateShopCart', params))
  })
}
// 设置购物车key
export function submitCartPro(params) {
  new Http().require({
    api: url.server_shop + '/mallGoods/setCartKey',
    param: qs.stringify(_bale('setCartKey', params))
  })
}

// 确认采购/一件代发 订单
export function getConfirmOrder(params) {
  new Http().require({
    api: url.server_shop + '/mallGoods/confirmOrder',
    param: qs.stringify(_bale('confirmOrder', params))
  })
}

//获取确认订单商品
export const getConfirmProduct = params =>
  new Http().require({
    api: url.server_shop + '/app/index/confirm_jin_qiao_order',
    param: qs.stringify(_bale('confirm_jin_qiao_order', params))
  })
// 提交确认订单
export const createOrder = params =>
  new Http().require({
    api: url.server_shop + '/app/index/submit_jin_qiao_order',
    param: qs.stringify(_bale('submit_jin_qiao_order', params))
  })
// 支付订单
export const payOrder = params =>
  new Http().require({
    api: url.server_shop + '/order/payOrder',
    param: qs.stringify(_bale('payOrder', params))
  })

export const ePay = params =>
  new Http().require({
    api: url.server_shop + '/wx/cardConsume',
    param: qs.stringify(_bale('cardConsume', params))
  })
//获取品牌
export const getBrandlList = params =>
  new Http().require({
    api:
      url.server_shop +
      '/index/get_brand_list' +
      GetParamString(_bale('get_brand_list', params)),
    methods: 'get'
  })
